<?php
 include("include/textcenter.php");
 include("include/db.php");
 $id = $_GET["id"];
 $sql = "SELECT * from vnf_customer where CustomerNo='$id'";
$result_cus = mysql_query($sql);
if(isset($_POST['SubmitAdd']))
{
    $description = $_POST['description'];
    $date_created= date('Y-m-d H:i:s', time());
    $order_status = $_POST['order_status'];
    $coupon_code = $_POST['coupon_code'];
    $coupon_value = $_POST['coupon_value'];
    $total = $_POST['total'];
    $BillToAddress = $_POST['BillToAddress'];
    $BillToCity = $_POST['BillToCity'];
    $BillToState = $_POST['BillToState'];
    $BillToZipCode = $_POST['BillToZipCode'];
    $BillToCountry = $_POST['BillToCountry'];
    $BillToPhone = $_POST['BillToPhone'];
    $BillToName = $_POST['BillToName'];
    $BillToCompany = $_POST['BillToCompany'];
    $BillToMessage = $_POST['BillToMessage'];
    $BillToFirstName = $_POST['BillToFirstName'];
    $BillToLastName = $_POST['BillToLastName'];
    $BillToEmail = $_POST['BillToEmail'];
    $ShipToAddress= $_POST['ShipToAddress'];
    $ShipToCity = $_POST['ShipToCity'];
    $ShipToState = $_POST['ShipToState'];
    $ShipToZipCode = $_POST['ShipToZipCode'];
    $ShipToCountry = $_POST['ShipToCountry'];
    $ShipToPhone = $_POST['ShipToPhone'];
    $ShipToEmail = $_POST['ShipToEmail'];
    $ShipToFirstName = $_POST['ShipToFirstName'];
    $ShipToLastName = $_POST['ShipToLastName'];
    $ShipToCompany = $_POST['ShipToCompany'];
    $ShipDate = $_POST['ShipDate'];
    $ShipNo = $_POST['ShipNo'];
    $ShipMethod = $_POST['ShipMethod'];
    $ShipDateUpdate = $_POST['ShipDateUpdate'];
    $GiftWrapYN = $_POST['GiftWrapYN'];
    $PartnerID = $_POST['PartnerID'];
    $Tax = $_POST['Tax'];
    $Add_Signature = $_POST['Add_Signature'];
    $ShippingType = $_POST['ShippingType'];
    $ShippingCost = $_POST['ShippingCost'];
    $StoreCreditAmount = $_POST['StoreCreditAmount'];
    $GiftCardNumber = $_POST['GiftCardNumber'];
    $GiftCardAmount = $_POST['GiftCardAmount'];
    $Subtotal = $_POST['Subtotal'];
    $TrackingNumber = $_POST['TrackingNumber'];
    $PrintYN = $_POST['PrintYN'];
    $StaffName = $_POST['StaffName'];
    $StaffMessage = $_POST['StaffMessage'];
    $MasterCard = $_POST['MasterCard'];
    $CVV = $_POST['CVV'];
    $ExpirationDate = $_POST['ExpirationDate'];
    $PaymentBy = $_POST['PaymentBy'];
    $ConfirmationNo = $_POST['ConfirmationNo'];
    $ShipMent = $_POST['ShipMent'];
    $Message = $_POST['Message'];
    $user_id = $_POST['CustomerNo'];
    $sql="insert into  vnf_shop_order(`description`, `user_id`, `date_created`, `order_status`
    , `coupon_code`, `coupon_value`, `total`, `BillToAddress`, `BillToCity`, `BillToState`, `BillToZipCode`, `BillToCountry`, `BillToPhone`
     , `BillToCompany`, `BillToMessage`, `BillToFirstName`, `BillToLastName`, `BillToEmail`, `ShipToAddress`, `ShipToCity`, `ShipToState`, `ShipToZipCode`, `ShipToCountry`, `ShipToPhone`
     , `ShipToEmail`, `ShipToFirstName`, `ShipToLastName`, `ShipToCompany`, `ShipDate`, `ShipNo`, `ShipMethod`
     , `GiftWrapYN`, `PartnerID`, `Tax`, `Add_Signature`, `ShippingType`, `ShippingCost`
     , `StoreCreditAmount`, `GiftCardNumber`, `GiftCardAmount`, `Subtotal`, `TrackingNumber`, `PrintYN`
     , `StaffName`, `StaffMessage`, `MasterCard`, `CVV`, `ExpirationDate`, `PaymentBy`, `ConfirmationNo`
     , `ShipMent`, `Message`
    ) 
     values('$description', '$id', '$date_created', '$order_status', '$coupon_code'
     , '$coupon_value', '$total', '$BillToAddress', '$BillToCity', '$BillToState', '$BillToZipCode', '$BillToCountry', '$BillToPhone'
     , '$BillToCompany', '$BillToMessage', '$BillToFirstName', '$BillToLastName', '$BillToEmail', '$ShipToAddress', '$ShipToCity', '$ShipToState', '$ShipToZipCode', '$ShipToCountry', '$ShipToPhone'
     , '$ShipToEmail', '$ShipToFirstName', '$ShipToLastName', '$ShipToCompany', '$ShipDate', '$ShipNo', '$ShipMethod'
     , '$GiftWrapYN', '$PartnerID', '$Tax', '$Add_Signature', '$ShippingType', '$ShippingCost'
     , '$StoreCreditAmount', '$GiftCardNumber', '$GiftCardAmount', '$Subtotal', '$TrackingNumber', 'N'
     , '$StaffName', '$StaffMessage', '$MasterCard', '$CVV', '$ExpirationDate', '$PaymentBy', '$ConfirmationNo'
     , '$ShipMent', '$Message'
     )";
    mysql_query($sql);
    $orid = "select order_id from vnf_shop_order order by order_id DESC limit 1 ";
    $orderID = mysql_query($orid);
    $ProID = $_POST['ProductID'];
    $Quantity = $_POST['Quantity'];
    if($ProID!= "" && $Quantity!="")
    {
        while ($o = mysql_fetch_array($orderID))
        {
            $Order = $o['order_id'];
        }
        $sqlselectpro = "select Product, SKU, Price from vnf_product where ProductNo=".$ProID;
        //echo $sqlselectpro;
        $product = mysql_query($sqlselectpro);
        while ($p = mysql_fetch_array($product))
        {
            $sqladd = "insert into vnf_shop_order_item(`OrderID`, `ProductNo`, `SKU`, `Product`, `Attribute`, `Quantity`, `Price`, `date_cretaed`) values('".$Order."', '".$ProID."', '".$p['SKU']."', '".$p['Product']."', 'NULL', $Quantity, '".$p['Price']."', '".date('Y-m-d H:i:s', time())."')";
          
            mysql_query($sqladd);
        }
    }
    echo '<meta http-equiv="Refresh" content="0;URL=customer_list.php" />';
}
?>
<html>
<head>
<meta name="description" content="Admin<?php echo $tagdescription?>">
<meta name="keywords" content="<?php echo $tagkeywords?> Main">
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title><?php echo $tagtitle?></title>

<script type="text/javascript" src="simpletreemenu.js">
/***********************************************
* Simple Tree Menu- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>
<link rel="stylesheet" type="text/css" href="simpletree.css" />
<LINK rel="StyleSheet" href="include/css_classes.css" type="text/css">
 <script src="jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="jquery-1.4.2.js"></script>
	<script type='text/javascript' src='jquery.autocomplete.js'></script>
	<link rel="stylesheet" type="text/css" href="jquery.autocomplete.css" />
	<script type="text/javascript">
		$(function(){
			$("#Product").autocomplete("docomplete1.php", {
				width: 260,
				matchContains: true,				
            });
			
			$("#Product").result(function(event, data, formatted) {
				$("#ProductID").val(data[1]);
			});

		});
	</script>

<style type="text/css">
input {
border: solid 1px gray;
}
</style>

</head>
<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0" link="#0000FF" vlink="#800080" alink="#FF0000" bgcolor="#FFFFFF">
<!-- -------------------Header---------------------------- -->
<?php include("include/header.php"); ?>
<!-- -------------------End Header---------------------------- -->


<form method="post" action="">
<table border="0" cellspacing="0" cellpadding="0" width="90%">

	<tr>
		<td width="12%" valign="top">
		<img border="0" src="public/images/homepage/spider16.gif" width="200" height="1"></td>
		<td width="1%" valign="top">
		<img border="0" src="public/images/homepage/spider16.gif" width="16" height="1"></td>
		<td width="86%" valign="top">
		<img border="0" src="public/images/homepage/spider16.gif" width="16" height="1"></td>
	</tr>	
	<tr>
		<!-- ///////////////////Begin Leftmenu/////////////////// -->
		<td width="12%" valign="top" bgcolor="#FFFFFF">
		<?php include("include/leftmenu.php"); ?>
		</td>
		<!-- ///////////////////End Leftmenu/////////////////// -->
		
		<td width="1%" valign="top" background="public/images/homepage/16.gif">&nbsp;</td>
		<td width="86%" valign="top">
<!-- -------------------Begin Body---------------------------- -->
<p class="title16B">&nbsp;<a href="order_list.php">Order</a> 
<div id="printthis"> 
<table  width="100%" width="70%" cellspacing="0" cellpadding="2" bordercolor="#FFECFF">
<tr style="border: 0 !important;">
		<td colspan="2">
<?php
while($row = mysql_fetch_array($result_cus))
{
 ?>
    <div style="float: left; width:100%; ">
        <fieldset>
            <legend>
                <b style="color: #F9F; font-size:15px;">Address Information</b>
            </legend>
            <div style="float: left; width:50%" align="left">
			BILL TO:<br />
            <table>
                <tr>
                    <td>
                        First name:
                    </td>
                    <td>
                        <input type="text" name="BillToFirstName" value="<?php echo $row['FirstName'] ?>" /><br/>
                        <input type="hidden" name="user_id" value="<?php echo  $row['CustomerNo']?>" /> 
                    </td>
                </tr>
                <tr>	
                    <td>
                        Last name:
                    </td>
                    <td>
                        <input type="text" name="BillToLastName" value="<?php echo $row['LastName'] ?>" /><br/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Email:
                    </td>
                    <td>
                        <input type="text" name="BillToEmail" value="<?php echo $row['Email'] ?>" /><br/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Address:
                    </td>
                    <td>
                        <input type="text" name="BillToAddress" value="<?php echo $row['Street'] ?>" /><br/>
                    </td>
                </tr>
                <tr>
                    <td>
                        City:
                    </td>
                    <td>
                        <input type="text" name="BillToCity" value="<?php echo $row['City'] ?>" /><br/>
                    </td>
                </tr>
                <tr>
                    <td>
                        State:
                    </td>
                    <td>
                        <input type="text" name="BillToState" value="<?php echo $row['State'] ?>" /><br/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Zipcode:
                    </td>
                    <td>
                        <input type="text" name="BillToZipCode" value="<?php echo $row['Zip'] ?>" /><br/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Country:
                    </td>
                    <td>
                        <input type="text" name="BillToCountry" value="<?php echo $row['Country'] ?>" /><br/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Phone:
                    </td>
                    <td>
                        <input type="text" name="BillToPhone" value="<?php echo $row['Phone'] ?>" /><br/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Company:
                    </td>
                    <td>
                        <input type="text" name="BillToCompany" value="<?php echo $row['Company'] ?>" /><br/>
                    </td>
                </tr>
            </table>
		
			</div>
            <div style="float: left; width:50%;">
                SHIP TO:<br />
    			<table>
                <tr>
                    <td>
                        First name:
                    </td>
                    <td>
                        <input type="text" name="ShipToFirstName" value="<?php echo $row['FirstName'] ?>" /><br/>
                    </td>
                </tr>
                <tr>	
                    <td>
                        Last name:
                    </td>
                    <td>
                        <input type="text" name="ShipToLastName" value="<?php echo $row['LastName'] ?>" /><br/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Email:
                    </td>
                    <td>
                        <input type="text" name="ShipToEmail" value="<?php echo $row['Email'] ?>" /><br/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Address:
                    </td>
                    <td>
                        <input type="text" name="ShipToAddress" value="<?php echo $row['Street'] ?>" /><br/>
                    </td>
                </tr>
                <tr>
                    <td>
                        City:
                    </td>
                    <td>
                        <input type="text" name="ShipToCity" value="<?php echo $row['City'] ?>" /><br/>
                    </td>
                </tr>
                <tr>
                    <td>
                        State:
                    </td>
                    <td>
                        <input type="text" name="ShipToState" value="<?php echo $row['State'] ?>" /><br/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Zipcode:
                    </td>
                    <td>
                        <input type="text" name="ShipToZipCode" value="<?php echo $row['Zip'] ?>" /><br/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Country:
                    </td>
                    <td>
                        <input type="text" name="ShipToCountry" value="<?php echo $row['Country'] ?>" /><br/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Phone:
                    </td>
                    <td>
                        <input type="text" name="ShipToPhone" value="<?php echo $row['Phone'] ?>" /><br/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Company:
                    </td>
                    <td>
                        <input type="text" name="ShipToCompany" value="<?php echo $row['Company'] ?>" /><br/>
                    </td>
                </tr>
                <tr>
                    <td>
                        Message:
                    </td>
                    <td>
                        <textarea name="Message" cols="35" rows="5"></textarea>
                    </td>
                </tr>
            </table>
            </div>
            </fieldset>
            </div>
		</td>
<?php
    }
?>		
	</tr>
    <tr>
        <td>
            <fieldset>
                <legend>
                    <b style="color: #F9F; font-size:15px;">Add product</b>
                </legend>
                <table>
                    <tr>
                        <td>
                            ProductNo
                        </td>
                        <td>
                            <input type="text" name="Product" id="Product" />
                            <input type="hidden" name="ProductID" id="ProductID" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Quantity
                        </td>
                        <td>
                            <input type="text" name="Quantity" id="Quantity" value="1" />
                        </td>
                    </tr>
                </table>
            </fieldset>
        </td>
        <td>
            <fieldset>
                <legend>
                    <b style="color: #F9F; font-size:15px;">Coupon</b>
                </legend>
                <table>
                    <tr>
                        <td>
                            Coupon Code
                        </td>
                        <td>
                            <input type="text" name="coupon_code"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Coupon Value
                        </td>
                        <td>
                            <input type="text" name="coupon_value" />
                        </td>
                    </tr>
                </table>
            </fieldset>
        </td>
    </tr>
    <tr>
          <td>
            <fieldset>
                <legend>
                    <b style="color: #F9F; font-size:15px;">Shipping Information</b>
                </legend>
                <table>
                    <tr>
                        <td>
                            Method
                        </td>
                        <td>
                            <input type="text" name="ShipMethod" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Ship Date
                        </td>
                        <td>
                            <input type="text" name="ShipDate"/>
                        </td>
                    </tr>
                     <tr>
                        <td>
                            Shipper No
                        </td>
                        <td>
                            <input type="text" name="ShipNo"/>
                        </td>
                    </tr>
                    <!--<tr>
                        <td>
                            Shipper No
                        </td>
                        <td>
                            <input type="text" name="ShipNo"/>
                        </td>
                    </tr>-->
                    <tr>
                        <td>
                            Confirmation No
                        </td>
                        <td>
                            <input type="text" name="ConfirmationNo"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Shipment Tracking
                        </td>
                        <td>
                            <input type="text" name="ShipMent"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Shipping Cost
                        </td>
                        <td>
                            <input type="text" name="ShippingCost"/>
                        </td>
                    </tr>
                </table>
            </fieldset>
        </td>
        <td>
            <fieldset>
                <legend>
                    <b style="color: #F9F; font-size:15px;">Credit Card Information</b>
                </legend>
                <table>
                    <tr>
                        <td>
                            Store Credit
                        </td>
                        <td>
                            <input type="text" name="StoreCreditAmount" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Payment By
                        </td>
                        <td>
                            <input type="text" name="PaymentBy" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Expiration Date
                        </td>
                        <td>
                            <input type="text" name="ExpirationDate"/>
                        </td>
                    </tr>
                     <tr>
                        <td>
                            Card number
                        </td>
                        <td>
                            <input type="text" name="MasterCard"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            CVV
                        </td>
                        <td>
                            <input type="text" name="CVV"/>
                        </td>
                    </tr>
                </table>
            </fieldset>
        </td>   
    </tr>
    <tr>
        <td>
                <table>
                    <tr>
                        <td>
                            Sales Tax	
                        </td>
                        <td>
                            <input type="text" name="Tax" />
                        </td>
                    </tr>
                   
                     <tr>
                        <td>
                            Total Due
                        </td>
                        <td>
                            <input type="text" name="total"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Subtotal
                        </td>
                        <td>
                            <input type="text" name="Subtotal"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Staff Message
                        </td>
                        <td>
                            <input type="text" name="StaffMessage"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Staff Name
                        </td>
                        <td>
                            <input type="text" name="StaffName"/>
                        </td>
                    </tr>
                    
                </table>
        </td>
        <td>
            <table>
                <tr>
                        <td>
                            Add Signature
                        </td>
                        <td>
                            <input type="text" name="Add_Signature"/>
                        </td>
                    </tr>
                <tr>
                        <td>
                            Partner
                        </td>
                        <td>
                            <select name="PartnerID">
                             <?php
                                $sql="select * from  tblpartners";
                                $partner =  mysql_query($sql);
                                 while($part = mysql_fetch_array($partner))
                                {
                            ?>
                                <option value="<?php echo $part['PartnerID'] ?>">
                            <?php echo $part['Title']?>
                                </option>
                            <?php
                                }
                            ?>
                            </select>
                        </td>
                    </tr>
                 <tr>
                        <td>
                            GiftCard
                        </td>
                        <td>
                            <input type="text" name="GiftCardAmount"/>
                        </td>
                    </tr>
                <tr>
                        <td>
                            Order status	
                        </td>
                        <td>
                            <select size="1" name="order_status">
                            <?php
                            ?>
                                <option value="0">Not complete</option>
                                <option value="1">Complete</option>
                                <option value="2">Shipping</option>
                			</select>
                        </td>
                    </tr>
                <tr>
                        <td>
                            GiftWrapYN	
                        </td>
                        <td>
                            <select size="1" name="GiftWrapYN">
                            <?php
                            ?>
                                <option value="1">Yes</option>
                                <option value="0">No</option>
                			</select>
                        </td>
                    </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td colspan="2" valign="top">
        Description&nbsp;&nbsp;&nbsp;<textarea name="description" cols="45" rows="10"></textarea>
        </td>
    </tr>
   <tr>
    <td colspan="2">
        <input type="submit" name="SubmitAdd" value="Add New Order" />
    </td>
   </tr>
</table>


<!-- -------------------End Body---------------------------- -->

&nbsp;</td>
	</tr>

</table>
</form>
<!-- ----------------------------------------------- -->
<!-- \\\\\\\\\\\\\\\\\\\\\Begin Footer\\\\\\\\\\\\\\\\\\\\\ -->
<?php include("include/footer.php"); ?>
<!-- \\\\\\\\\\\\\\\\\\\\\End Footer\\\\\\\\\\\\\\\\\\\\\ -->
</body>

</html>